Lesson 5 - if statements quiz
Quiz
What should replace XXXX in the following code?
if x > 5:
print "foo"
XXXX :
print "boo"
- foo
- elif
- if
- else
What are the three main components of a if statement?
- else if
expression
colon - expression
true block
colon - expression
true block
false block - colon
true block
false block
Which of the following if statements would make a number ALWAYS negative?
- if x < 0:
x = x * -1 - if x > 0:
x = x * -1 - if x < 0:
x = int(x) - if x != 0:
x = int(x)
What should replace XXXXX?
if x==5:
print "x is 5"
XXXXX
print "x is 4"
else:
print "x is not 5 or 4"
- else if x == 4:
- elif x==4:
- else:
- if x== 4:
What is wrong with this code?
if x>5:
print "x is bigger than 5"
- Nothing
- print should be indented
- x is not a number
- there should be a colon at the end of the print line